#include "common.h"
S4B GetPCB(PPCBITEM pitem,U4B type)
{
   PPROCESS ppro=process;
   if(pitem->pid==MYSELF)
   { ppro=WhoRunning;}
   else
   { 

        while(ppro!=PTR_INVALID && ppro->p_pid!=pitem->pid &&ppro->p_pprocessnext!=process)
        { 
          ppro=ppro->p_pprocessnext;
        }

        if(ppro==PTR_INVALID || ppro->p_pid!=pitem->pid) 
        { return ARTIST_ERROR_PROCESSNOTEXIST;}
   }

   switch(pitem->type)
   {
       case PCB_PID:
       {
         (pitem->pvalue)=ppro->p_pid;break;
       }
       case PCB_SIGNALRETURN:
       {
          pitem->pvalue=ppro->p_signalreturn;break;
       }
       case PCB_WAITTICK:
       {  pitem->pvalue=ppro->p_waittick;break;}
	   case PCB_WAITSIGNAL:
	   {  pitem->pvalue=ppro->p_waitsignal;break;}
	   case PCB_WAITSOURCE:
	   {  pitem->pvalue=ppro->p_waitsource;break;}
       default:{return ARTIST_ERROR_NOTSUPPORTED;}
   }
   return ARTIST_ERROR_OK;
}
S4B GetPCBITEM(PPCBITEM pitem)
{
   S4B value;
   SystemCallInterrupt((U4B)SYSCALL_GETPCB,(U4B)pitem,NULL,(U4B)&value);
   return value;
}
